import Vue from "vue";
import Vuex, { createLogger } from "vuex";
import persistence from "vuex-uniapp-persistence";
// 引入模块
import system from "./modules/system";
import user from "./modules/user";
import address from "@/store/modules/address";
Vue.use(Vuex);

// 构建store的主仓库
const store = new Vuex.Store({
  state: {
    username: "黑马",
  },
  mutations: {
    setUserName(state, newUsername) {
      state.username = newUsername;
    },
  },
  actions: {},
  getters: {},
  modules: {
    system,
    user,
    address,
  },
  // 通过plugins配置持久化的插件
  plugins: [persistence(), createLogger()],
});
// 进行默认导出
export default store;
